package com.livesource.client.web.sourceCode.code;

import com.google.gwt.user.client.ui.VerticalPanel;
import com.livesource.client.model.entry.ProjectClass;
import com.livesource.client.web.sourceCode.SourceCodePage;

import edu.ycp.cs.dh.acegwt.client.ace.AceEditor;
import edu.ycp.cs.dh.acegwt.client.ace.AceEditorMode;
import edu.ycp.cs.dh.acegwt.client.ace.AceEditorTheme;

public class AceGWTEditor {

	private AceEditor editor;

	public void showCodeEditor(ProjectClass entity) {

		editor = new AceEditor();
		editor.setSize("700px", "500px");

		VerticalPanel mainPanel = new VerticalPanel();
		mainPanel.setSize("700px", "500px");
		mainPanel.setBorderWidth(1);

		mainPanel.add(editor);

		SourceCodePage.featureVisualizationPanel.add(mainPanel);

		// start the first editor and set its theme and mode
		// must be called before calling setTheme/setMode/etc.
		editor.startEditor();

		editor.setTheme(AceEditorTheme.ECLIPSE);
		editor.setMode(AceEditorMode.JAVA);

		editor.setText(entity.getFileContent());

		editor.setHScrollBarAlwaysVisible(false);

		editor.gotoLine(0);
	}

}
